<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app"></div>
    <script src="./libs/react.js"></script>
    <script src="./libs/react-dom.js"></script>
    <script src="./libs/babel.min.js"></script>
    <script type="text/babel">
      // 跨组件之间传参，在各个组件之间进行传递
      const mainContext = React.createContext();
      console.log(mainContext);
      const { Provider } = mainContext;

      function B() {
        const c = React.useContext(mainContext);
        console.log(c);
        return (
          <>
            <p>我是一个组件B</p>
          </>
        );
      }

      function App() {
        return (
          <>
            <B />
          </>
        );
      }

      ReactDOM.render(
        <Provider value={{ title: "标题", name: "dada", color: "orange" }}>
          <App />
        </Provider>,
        document.getElementById("app")
      );
    </script>
  </body>
</html>
